package com.terana.lbs.marketing.web.consumer;

import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.pojo.marketing.param.UserCouponsParam;
import com.terana.lbs.marketing.web.service.CouponService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class LocationShopConsumer {
    @Autowired
    private CouponService couponService;
    @StreamListener("location-shop-input")
    public void locationshop(UserCouponsParam param){
        log.info("运营服务接收定位参数消息:{}",param);
        //消息中只有shopId userId couponId activityId
        try{
            couponService.locationReciveCoupon(param);
        }catch (BusinessException e){
            log.error("定位上报 领取优惠券异常",e);
        }catch (Throwable e){
            log.error("定位上报 领取系统异常",e);
            throw e;
        }
    }
}
